home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mc51bugs / q32515 < prev    next >
Text File  |  1988-07-20  |  1KB  |  39 lines

  1. Q32515 Strnset Sets One Too Many Bytes in Some Cases
  2. C Compiler
  3. 5.10   | 5.10
  4. MS-DOS | OS/2
  5.  
  6. Summary:
  7.    If you attempt to set the first N+1 bytes of a string that is N
  8. bytes long using the strnset function, the function will incorrectly
  9. write one too many bytes. The function is designed to set only
  10. strlen(string) bytes of string if it is called with a number that is
  11. greater than strlen(string); however, as illustrated in the following
  12. example, if the strnset function is called with exactly
  13. strlen(string)+1 as the number of characters to set, it will write an
  14. extra byte:
  15.  
  16.  
  17. #include <string.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20.  
  21. char string1[8] = "aaaaaaa\0";
  22. char string2[3] = "bb\0";
  23.  
  24. main()
  25. {
  26. char *dest;
  27. dest = strnset(string1, 'c', 8);
  28. printf("String1 should be 'ccccccc'. It is %s\n",string1);
  29. }
  30.  
  31.    Microsoft has confirmed this to be a problem in Version 5.10
  32. of the C compiler.  We are researching this problem and will post new
  33. information as it becomes available.
  34.  
  35.  
  36.  
  37. Keywords:  buglist5.10 qfbv
  38. Updated  88/07/21 03:19
  39.